/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package dao;


import com.mysql.jdbc.CallableStatement;
import java.sql.Connection;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.Scanner;
import pojo.TheLoaiPOJO;

/**
 *
 * @author HP
 */
public class TheLoaiDAO {
    Scanner scan=new Scanner(System.in);
    MySqlDataAccessHelper helper=new MySqlDataAccessHelper();
    public ArrayList<TheLoaiPOJO>  layDanhSach_TheLoai(){
        ArrayList<TheLoaiPOJO> ds=new ArrayList<TheLoaiPOJO>();
        try
        {

          helper.open();
            Connection cn=helper.getConnection();
            CallableStatement statement =(CallableStatement) cn.prepareCall("{call sp_LayDanhSach_TheLoai()}");
            statement.execute();
            ResultSet rs = statement.getResultSet();
            //

            while(rs.next())
            {
                TheLoaiPOJO tl=new TheLoaiPOJO();
                tl.setMaTheLoai(rs.getInt("MaTheLoai"));
                tl.setTenTheLoai(rs.getNString("TenTheLoai"));
                ds.add(tl);
            }
            helper.close();
            return ds;
        }
        catch(Exception ex)
        {
        System.out.println(ex.getMessage());
        return ds;
    }
}
}
